<include file="./Tpl/Home/top.html"/>
<include file="./Tpl/Home/header.html" />
<!--交易页面的子导航区-->
<include file="./Tpl/Home/user_nav.html" />

<div class="container">
<!--全站交易记录-->
<div class="trade-part trade-part-hd mt20">
  <div class="trade-hd">
        <h5><i class="icon_condition"></i>中元币认购 &nbsp;&nbsp;&nbsp;&nbsp;
		<!--volist name="ilist" id="vo"><span class="phase <eq name='vo.status' value='0'>p_cur</eq">{$vo.title}</span></volist--></h5>
  </div>
  <notempty name="issued">
  <div class="trade-hd" style="border:1px solid #ccc;padding:10px;margin:10px 0px;">{$info}</div>
  <else/>
  <div class="trade-hd" style="border:1px solid #ccc;padding:10px;margin:10px 0px;">暂无认购活动！</div>
  </notempty>
  <div class="md">
    <notempty name="issued">
    <div class="my-grid" id="order-grid" style="margin-bottom:20px;">
	    <form action="{$path}/User/buy" method="post" id="formid">
		    <input type="hidden" name="issueid" value="{$issueid}"/>
			<table class="items table table-striped table-bordered table-condensed chkreal">
			<tbody>
			<tr><td>市场总量：</td><td><input type="text" value="{$issued|default=0}" readonly/></td></tr>
			<tr><td>已购总量：</td><td><input type="text" value="{$buysum|default=0}" readonly/></td></tr>
			<tr><td>剩余总量：</td><td><input type="text" value="{$surplus|default=0}" readonly/></td></tr>
			<tr><td>认购价格：</td><td><input type="text" name="price" value="{$price|default=0}" readonly/></td></tr>
			<tr><td>认购限量：</td><td><input type="text" name="limit" value="{$limit|default=0}" readonly/></td></tr>
            <tr><td>已购数量：</td><td><input type="text" name="sum" value="{$sum|default=0}" readonly/></td></tr>
			<tr><td>还可认购：</td><td><input type="text" name="ablenum" value="{$ablenum|default=0}" readonly/></td></tr>
			<tr><td>认购数量：</td><td><input type="text" name="num" placeholder="请输入认购数量"/></td></tr>
			<tr><td>人民币：</td><td><input type="text" name="rmb" value="0" readonly/></td></tr>
			<tr><td>验证码：</td><td><input type="text" name="code" placeholder="请输入验证码" style="width:114px;"/><img id="refresh" style="vertical-align:middle;height:30px;margin-left:5px;" onclick="document.getElementById('refresh').src='{$path}/Login/checkcode/t/'+Math.random()" src="{$path}/Login/checkcode/" title="看不清？点一下"/></td></tr>
			<tr><td colspan=2><input type="button" id="subbtn" class="btn" value="确定"/></td></tr>
			</tbody>
			</table>
		</form>
		<script language="javascript">
		$(document).ready(function(){
			$('input[name="num"]').keyup(function(){
				var price = $('input[name="price"]').val();
				var num = $('input[name="num"]').val();
				var psum = price * num;
				psum = String(psum);

				var pos = psum.indexOf('.');
				if(pos != -1){
					if(psum.substring(0,pos)!='') {
						len = psum.substring(pos+1,psum.length);
						if(len.length <= 6) {
							$('input[name="rmb"]').val(psum);
						}else{
							$('input[name="rmb"]').val(0);
						}
					}else{
						$('input[name="rmb"]').val(0);
					}
				}else{
					$('input[name="rmb"]').val(psum);
				}
			});
			$('input[name="num"]').change(function(){
				var price = $('input[name="price"]').val();
				var num = $('input[name="num"]').val();
				var psum = price * num;
				psum = String(psum);

				var pos = psum.indexOf('.');
				if(pos != -1){
					if(psum.substring(0,pos)!='') {
						len = psum.substring(pos+1,psum.length);
						if(len.length <= 6) {
							$('input[name="rmb"]').val(psum);
						}else{
							$('input[name="rmb"]').val(0);
						}
					}else{
						$('input[name="rmb"]').val(0);
					}
				}else{
					$('input[name="rmb"]').val(psum);
				}
			});
		});
		</script>
	</div>
	</notempty>
	<div class="my-grid" id="order-grid">
	    <span style="font-size:17px;color:#333;font-weight:bold;margin-right:70px;">认购纪录</span>

		<table class="items table table-striped table-bordered table-condensed saferoom">
		<thead>
		<tr><th>数量</th><th>已回购数量</th><th>价格</th><th>总额</th><th>时间</th><th width="10%">状态</th><th width="10%">操作</th></tr>
		</thead>
		<tbody>
		<volist name="list" id="vo" empty="$empty">
		<tr><td class="chkTit">{$vo.num|default='0'}</td><td>{$vo.downnum|default='0'}</td>
            <td>￥ {$vo.price|default='0'}</td><td>￥ {$vo.sumprice|default='0'}</td>
            <td>{$vo.addtime|default='无'}</td>
            <td>
                <if condition='$vo.status eq 0'>已认购
                    <td><a href="/?s=Home/User/hg/id/{$vo.id}">申请回购</a></td>
                    <elseif condition='$vo.status eq -1'/>等待回购...
                    <td>耐心等待...</td>
                    <else/>已回购
                    <td>回购已成功</td>
                </if></td>
         </tr>
		</volist>
		</tbody>
		</table>
	</div>
  </div>
</div>
</div>
<!--尾部-->
<include file="./Tpl/Home/footer.html" />
<!-- footer -->

<div class="modal hide fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>

<!--[if IE 6]><script src="/js/ie-6.js"></script><![endif]-->
<script type="text/javascript" src="/Public/Home/js/jquery.SuperSlide.js"></script>
<script type="text/javascript" src="/Public/Home/js/slideTxtBox.js"></script>
<script type="text/javascript" src="/Public/Home/js/bootbox.js"></script>
<script type="text/javascript" src="/Public/Home/js/box.js"></script>
<script type="text/javascript" src="/Public/Home/js/lang.js"></script>
<script type="text/javascript" src="/Public/Home/js/responseHandler.js"></script>
<script type="text/javascript" src="/Public/Home/js/jquery.yiigridview.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
jQuery(function($) {
jQuery('body').popover({'selector':'a[rel=popover]'});
jQuery('#order-grid').yiiGridView({'ajaxUpdate':['order-grid'],'ajaxVar':'ajax','pagerClass':'pagination','loadingClass':'grid-view-loading','filterClass':'filters','tableClass':'items table table-striped table-bordered table-condensed','selectableRows':1,'enableHistory':false,'updateSelector':'{page}, {sort}','filterSelector':'{filter}','pageVar':'CurrencyTransaction_page'});
});
/*]]>*/

$(document).ready(function(){
	$('#subbtn').click(function(){
	    var num = $('input[name=num]').val();
	
	    if(num=="" || num <= 0){
		    msgDalog("请输入认购数量！","",0);
		}else if(isNaN(num)){
			msgDalog('认购数量应为数字！');
			$('input[name=goldnum]').val('');
			return false;
		}else if($('input[name=code]').val()==""){
		    msgDalog("请输入验证码！","",0);
		}else{
		    var pos = num.indexOf('.');
			if(pos != -1){
				if(num.substring(0,pos)=='') {
					msgDalog('认购数量不合法！');
					return false;
				}
				len = num.substring(pos+1,num.length);
				if(len.length > 6) {
					msgDalog('认购数量小数位数不能超过8位！');
					return false;
				}
			}else{
		        $('#formid').submit();
			}
		}
	});
});
</script>
</body>
</html>